package com.djsearch.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.djsearch.R;
import com.djsearch.bean.GroupBuyGoods;
import com.djsearch.bean.LvYouGoodsListBean;
import com.djsearch.bean.TravelBean;
import com.djsearch.data.RequestImage;
/**
 * 旅游页面listview适配器
 * @author chenyang2
 *
 */
public class LvYouListViewAdapter extends BaseAdapter {


	


	private Context mContext;
	private List<LvYouGoodsListBean> travelList;
	
	public LvYouListViewAdapter(Context context,List<LvYouGoodsListBean> travelList) {
		mContext = context;
		this.travelList = travelList;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return travelList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return travelList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public void refreshData(List<LvYouGoodsListBean> list) {
		travelList = list;
		notifyDataSetChanged();
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		if (convertView == null) {
			LayoutInflater layoutInflater = ((Activity) mContext).getLayoutInflater();
			convertView = layoutInflater.inflate(R.layout.lvyou_listview_item, parent, false);
			convertView.setTag(convertView);
		} else {
			convertView = (View) convertView.getTag();
		}
		//旅游图片
		ImageView goodsImg = (ImageView)convertView.findViewById(R.id.lvyouIcon);
		RequestImage.getIntance(null, "GroupShop").download("http://www.cnlxs.org/images/" + travelList.get(position).getSale_DataSmallImage(), 
				goodsImg);
		//出发地
		TextView chuFaPlace = (TextView)convertView.findViewById(R.id.chuFaPlaceText);
//		chuFaPlace.setText(travelList.get(position).getPlace());
		chuFaPlace.setText(travelList.get(position).getSale_DataCName());
		//游玩地
		TextView playPlace = (TextView)convertView.findViewById(R.id.playPlaceText);
		playPlace.setText(travelList.get(position).getSale_DataSmallAbout());
		//描述
		TextView describe = (TextView)convertView.findViewById(R.id.describeText);
		//价格
		TextView playPrice = (TextView)convertView.findViewById(R.id.priceText);
		playPrice.setText(travelList.get(position).getSale_DataTwo());
		//代金券抵扣前
		TextView diKouPrice = (TextView)convertView.findViewById(R.id.diKouPriceText);
		diKouPrice.setText(travelList.get(position).getDaiJinQuanDi());
		return convertView;
	}




	
}
